<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<div class="t_bar">
    <span class="color_red">*</span>成果完成单位情况（此栏涉及到的知识产权问题由填报单位负责）
</div>
<table>
    <col style="width: 15%" />
    <col style="width: 10%" />
    <col style="width: 32%" />
    <col style="width: 13%" />
    <col style="width: 30%" />
    <tr>
        <td align="right" colspan="2">第一完成单位名称：</td>
        <td colspan="3">
            <input name="proposal/pay_offs_org" style="width: 574px;" label="第一完成单位名称"
                class="required" maxlength="50"
                value="<x:out select="$xmlData/data/proposal/pay_offs_org"/>" />
        </td>
    </tr>
    <tr>
        <td align="right" colspan="2">组织机构代码/统一社会信用代码：</td>
        <td colspan="3">
            <input name="proposal/org_no" style="width: 574px;" label="组织机构代码/统一社会信用代码"
                class="required orgShxyCard" maxlength="18"
                value="<x:out select="$xmlData/data/proposal/org_no"/>" />
        </td>
    </tr>
    <tr>
        <td align="right">通讯地址：</td>
        <td colspan="2">
            <input name="proposal/com_address" style="width: 80%" label="通讯地址" class="required"
                maxlength="100" value="<x:out select="$xmlData/data/proposal/com_address"/>" />
        </td>
        <td align="right">邮政编码：</td>
        <td>
            <input name="proposal/zip_code" label="邮政编码" class="required" maxlength="6"
                onkeyup="this.value=this.value.replace(/\D/g,'')"
                onafterpaste="this.value=this.value.replace(/\D/g,'')"
                value="<x:out select="$xmlData/data/proposal/zip_code"/>" />
        </td>
    </tr>
    <tr>
        <td align="right">网址：</td>
        <td colspan="2">
            <input name="proposal/url" label="网址" style="width: 80%" class="required" maxlength="50"
                value="<x:out select="$xmlData/data/proposal/url"/>" />
        </td>
        <td align="right">传真：</td>
        <td>
            <input name="proposal/fax" label="传真 " class="required" maxlength="40"
                value="<x:out select="$xmlData/data/proposal/fax"/>" />
        </td>
    </tr>
    <tr>
        <td align="right">单位联系人：</td>
        <td colspan="2">
            <input name="proposal/org_contact_psn_cname" style="width: 80%" label="单位联系人"
                class="required" maxlength="50"
                value="<x:out select="$xmlData/data/proposal/org_contact_psn_cname"/>" />
        </td>
        <td align="right">电话：</td>
        <td>
            <input name="proposal/org_contact_psn_mobile" label="电话 " class="required"
                maxlength="40"
                value="<x:out select="$xmlData/data/proposal/org_contact_psn_mobile"/>" />
        </td>
    </tr>
    <tr>
        <td align="right">电子邮件：</td>
        <td colspan="4">
            <input name="proposal/org_contact_psn_email" style="width: 670px;" label="电子邮件"
                class="required email" maxlength="50"
                value="<x:out select="$xmlData/data/proposal/org_contact_psn_email"/>" />
        </td>
    </tr>
    <tr>
        <td align="right" rowspan="4">单位属性：<br/>（单选）</td>
        <td colspan="4">
            <c:set var="results_registration_form11_1_value">
                <x:out select="$xmlData/data/proposal/results_registration_form11_1_value" />
            </c:set>
            <cpt:checkbox key="results_registration_form11_1" name="results_registration_form11_1"
                repeatColumn="3" value="${results_registration_form11_1_value }"
                onClick="setOrgType('',1);" tagType="radio"></cpt:checkbox>
            <input type="hidden" id="results_registration_form11_1_value"
                name="proposal/results_registration_form11_1_value" class="required"
                value="${results_registration_form11_1_value}" label="单位属性">
            <input type="hidden" name="proposal/results_registration_form11_1_name"
                value="<x:out select="$xmlData/data/proposal/results_registration_form11_1_name" />">
        </td>
    </tr>
    <tr>
        <td align="right" rowspan="2">企业：</td>
        <td colspan="3">
            <c:set var="results_registration_form11_2_value">
                <x:out select="$xmlData/data/proposal/results_registration_form11_2_value" />
            </c:set>
            <cpt:checkbox key="results_registration_form11_2" name="results_registration_form11_2"
                repeatColumn="4" value="${results_registration_form11_2_value }"
                onClick="setOrgType('3',2);" tagType="radio"></cpt:checkbox>
            <input type="hidden" id="results_registration_form11_2_value"
                name="proposal/results_registration_form11_2_value" class="required"
                value="${results_registration_form11_2_value}" label="单位属性">
            <input type="hidden" name="proposal/results_registration_form11_2_name"
                value="<x:out select="$xmlData/data/proposal/results_registration_form11_2_name" />">
        </td>
    </tr>
    <tr>
        <td colspan="3">
            <c:set var="results_registration_form11_3_value">
                <x:out select="$xmlData/data/proposal/results_registration_form11_3_value" />
            </c:set>
            <cpt:checkbox key="results_registration_form11_3" name="results_registration_form11_3"
                repeatColumn="3" value="${results_registration_form11_3_value }"
                onClick="setOrgType('3',3);" tagType="radio"></cpt:checkbox>
            <input type="hidden" id="results_registration_form11_3_value"
                name="proposal/results_registration_form11_3_value" class="required"
                value="${results_registration_form11_3_value}" label="单位属性">
            <input type="hidden" name="proposal/results_registration_form11_3_name"
                value="<x:out select="$xmlData/data/proposal/results_registration_form11_3_name" />">
        </td>
    <tr>
        <td colspan="4">
            <c:set var="results_registration_form11_4_value">
                <x:out select="$xmlData/data/proposal/results_registration_form11_4_value" />
            </c:set>
            <c:set var="results_registration_form11_4_other">
                <x:out select="$xmlData/data/proposal/results_registration_form11_4_other" />
            </c:set>
            <cpt:checkbox key="results_registration_form11_4" name="results_registration_form11_4"
                repeatColumn="1" value="${results_registration_form11_4_value }" lastOther="true"
                otherId="results_registration_form11_4_other" onClick="setOrgType('4',4);"
                otherValueName="${results_registration_form11_4_other }" tagType="radio"></cpt:checkbox>
            <input type="text" id="results_registration_form11_4_other"
                name="proposal/results_registration_form11_4_other" mxlength="50"
                style="border: none; border-bottom: 1px solid gray; width: 100px;" label="单位属性-->其他"
                value="<x:out select="$xmlData/data/proposal/results_registration_form11_4_other"/>" />
            <input type="hidden" id="results_registration_form11_4_value"
                name="proposal/results_registration_form11_4_value" class=""
                value="${results_registration_form11_4_value}" label="单位属性-->其他">
            <input type="hidden" name="proposal/results_registration_form11_4_name"
                value="<x:out select="$xmlData/data/proposal/results_registration_form11_4_name" />">
        </td>
    </tr>
    <tr>
        <td align="right">所在省市（县）：</td>
        <td colspan="2">
            <input name="proposal/province_and_city" label="所在省市（县）" style="width: 80%"
                class="required" maxlength="100"
                value="<x:out select="$xmlData/data/proposal/province_and_city"/>" />
        </td>
        <td align="right">归口管理部门：</td>
        <td>
            <c:set var="recomend_org">{'id':'<x:out
                    select="$xmlData/data/proposal/recomend_org_value" />','name':'<x:out
                    select="$xmlData/data/proposal/recomend_org_name" />'}</c:set>
            <cpt:tree key="recommended_org" cacheable="false" className="hn_iuput_kuang "
                readonly="true" value="${recomend_org}" label="归口管理部门" id="recomend_org"
                onlyChooseLeaf="false" showPattern="all" shieldPattern="0" topCheckbox="true"
                onClick="initTreeValueExt" />
            <input type="hidden" id="recomend_org_value" name="proposal/recomend_org_value"
                class="required"
                value="<x:out select="$xmlData/data/proposal/recomend_org_value" />" label="归口管理部门">
            <input type="hidden" name="proposal/recomend_org_name"
                value="<x:out select="$xmlData/data/proposal/recomend_org_name" />">
        </td>
    </tr>
    <tr>
        <td align="right">成果转让意向与范围：</td>
        <td colspan="4">
            <c:set var="results_registration_form12_value">
                <x:out select="$xmlData/data/proposal/results_registration_form12_value" />
            </c:set>
            <cpt:checkbox key="results_registration_form12" name="results_registration_form12"
                repeatColumn="4" value="${results_registration_form12_value }" tagType="radio"></cpt:checkbox>
            <input type="hidden" id="results_registration_form12_value"
                name="proposal/results_registration_form12_value" class="required"
                value="${results_registration_form12_value}" label="成果转让意向与范围">
            <input type="hidden" name="proposal/results_registration_form12_name"
                value="<x:out select="$xmlData/data/proposal/results_registration_form12_name" />">
        </td>
    </tr>
    <tr>
        <td align="right">成果转化联系人：</td>
        <td colspan="2">
            <input name="proposal/contact_psn_cname" style="width: 80%" label="成果转化联系人"
                class="required" maxlength="50"
                value="<x:out select="$xmlData/data/proposal/contact_psn_cname"/>" />
        </td>
        <td align="right">电话：</td>
        <td>
            <input name="proposal/contact_psn_mobile" label="电话 " class="required" maxlength="40"
                value="<x:out select="$xmlData/data/proposal/contact_psn_mobile"/>" />
        </td>
    </tr>
    <tr>
        <td align="right">电子邮件：</td>
        <td colspan="4">
            <input name="proposal/contact_psn_email" style="width: 670px;" label="电子邮件"
                class="required email" maxlength="50"
                value="<x:out select="$xmlData/data/proposal/contact_psn_email"/>" />
        </td>
    </tr>
</table>
<div class="t_bar">
    <span class="color_red">*</span>成果合作完成单位情况
</div>
<table id="eq_table1">
    <col style="width: 5%" />
    <col style="width: 5%" />
    <col style="width: 25%" />
    <col style="width: 35%" />
    <col style="width: 10%" />
    <col style="width: 10%" />
    <col style="width: 10%" />
    <thead>
        <tr>
            <th class="TblHead" align="center">选择</th>
            <th class="TblHead" align="center">序号</th>
            <th class="TblHead" align="center">单位名称</th>
            <th class="TblHead" align="center">通讯地址</th>
            <th class="TblHead" align="center">邮政编码</th>
            <th class="TblHead" align="center">联系人</th>
            <th class="TblHead" align="center">联系人电话</th>
        </tr>
    </thead>
    <tbody id="tab">
        <tr style="display: none;">
            <td align="center">
                <input type="radio" style="border: 0px; background-color: white;"
                    class="radiobutton" name="selMileStones">
            </td>
            <td align="center">
                <span name="completions|completion[0]@seq_no">[index]</span>
            </td>
            <td align="center">
                <input name="completions|completion[0]|org_name" style="width: 80%" label="单位名称"
                    class="required" value="" maxlength="50" />
            </td>
            <td align="center">
                <input name="completions|completion[0]|com_address" style="width: 80%" label="通讯地址"
                    class="required" value="" maxlength="100" />
            </td>
            <td align="center">
                <input name="completions|completion[0]|zip_code" style="width: 80%" label="邮政编码"
                    onkeyup="this.value=this.value.replace(/\D/g,'')"
                    onafterpaste="this.value=this.value.replace(/\D/g,'')" class="required" value=""
                    maxlength="6" />
            </td>
            <td align="center">
                <input name="completions|completion[0]|contact_psn_cname" style="width: 80%"
                    label="联系人" class="required" value="" maxlength="40" />
            </td>
            <td align="center">
                <input name="completions|completion[0]|contact_psn_tel" style="width: 80%"
                    label="联系人电话" class="required" value="" maxlength="20" />
            </td>
        </tr>

        <c:set value="0" var="index" scope="page" />
        <x:forEach select="$xmlData/data/completions/completion" var="completion">
            <c:choose>
                <c:when test="${index<10}">
                    <c:set value="0" var="flag" scope="page" />
                </c:when>
                <c:otherwise>
                    <c:set value="" var="flag" scope="page" />
                </c:otherwise>
            </c:choose>
            <tr>
                <td align="center">
                    <input type="radio" style="border: 0px; background-color: white;"
                        class="radiobutton" name="selMileStones">
                </td>
                <td align="center">
                    <span name="completions/completion[${flag}${index}]@seq_no"><x:out
                            select="$completion/@seq_no" /></span>
                </td>
                <td align="center">
                    <input name="completions/completion[${flag}${index}]/org_name" label="单位名称"
                        style="width: 80%" class="required"
                        value="<x:out select="$completion/org_name"/>" maxlength="50" />
                </td>
                <td align="center">
                    <input name="completions/completion[${flag}${index}]/com_address" label="通讯地址"
                        style="width: 80%" class="required"
                        value="<x:out select="$completion/com_address"/>" maxlength="100" />
                </td>
                <td align="center">
                    <input name="completions/completion[${flag}${index}]/zip_code" label="邮政编码"
                        style="width: 80%" class="required"
                        onkeyup="this.value=this.value.replace(/\D/g,'')"
                        onafterpaste="this.value=this.value.replace(/\D/g,'')"
                        value="<x:out select="$completion/zip_code"/>" maxlength="6" />
                </td>
                <td align="center">
                    <input name="completions/completion[${flag}${index}]/contact_psn_tel"
                        label="联系人电话" style="width: 80%" class="required"
                        value="<x:out select="$completion/contact_psn_tel"/>" maxlength="20" />
                </td>
            </tr>
            <c:set value="${index+1}" var="index" scope="page" />
        </x:forEach>
    </tbody>
</table>

<table width="98%" align="center" class="tab_btn">
    <tr>
        <td>
            <input class="button_02" name="cmdAddbefore" type=button value="添加"
                onclick="if(checkTabLimit('eq_table1',999,'成果合作完成单位情况内容最多只能填写999条')){addNewRow('eq_table1');showDateTag('eq_table1');}try{top.resizeFrame();}catch(e){};">
            <input class="button_02" name="cmdMovePrev" type=button value="上移"
                onclick="movePrev('eq_table1','selMileStones');">
            <input class="button_02" name="cmdMoveNext" type=button value="下移"
                onclick="moveNext('eq_table1','selMileStones');">
            <input class="button_02" name="cmddel" type=button value="删除"
                onclick="deleteSelectedRow('eq_table1','成果合作完成单位情况');">
        </td>
    </tr>
</table>
<script>
	/**
	 * by zk
	 * @deprecated 单位属性操作
	 * @param orgTypeValue 需要拆分字段传值需要判断 ，若为空需要特殊判断
	 * @seq 
	 */
	function setOrgType(orgTypeValue, seq) {
		var pay_offs_org_type = $("#pay_offs_org_type"); //成果单位完成类型，需拆分字段
		
		var results_registration_form11_1 = $("input:radio[name='results_registration_form11_1']");
		var results_registration_form11_2 = $("input:radio[name='results_registration_form11_2']");
		var results_registration_form11_3 = $("input:radio[name='results_registration_form11_3']");
		var results_registration_form11_4 = $("input:radio[name='results_registration_form11_4']");
		var results_registration_form11_1_value = $("#results_registration_form11_1_value");
		var results_registration_form11_2_value = $("#results_registration_form11_2_value");
		var results_registration_form11_3_value = $("#results_registration_form11_3_value");
		var results_registration_form11_4_value = $("#results_registration_form11_4_value");
		
		if (seq == "1") {
			var rrf1v = results_registration_form11_1_value.val();
			if (rrf1v == '01')
				orgTypeValue = '2';
			else if (rrf1v == '02')
				orgTypeValue = '1';
			else if (rrf1v == '03')
				orgTypeValue = '4';
			
			results_registration_form11_2.removeAttr("checked");
			results_registration_form11_3.removeAttr("checked");
			results_registration_form11_4.removeAttr("checked");
			results_registration_form11_2_value.val("");
			results_registration_form11_3_value.val("");
			results_registration_form11_4_value.val("");
		} else if (seq == '2') {
			results_registration_form11_1.removeAttr("checked");
			results_registration_form11_3.removeAttr("checked");
			results_registration_form11_4.removeAttr("checked");
			results_registration_form11_1_value.val("");
			results_registration_form11_3_value.val("");
			results_registration_form11_4_value.val("");
		} else if (seq == '3') {
			results_registration_form11_1.removeAttr("checked");
			results_registration_form11_2.removeAttr("checked");
			results_registration_form11_4.removeAttr("checked");
			results_registration_form11_1_value.val("");
			results_registration_form11_2_value.val("");
			results_registration_form11_4_value.val("");
		} else if (seq == '4') {
			results_registration_form11_1.removeAttr("checked");
			results_registration_form11_2.removeAttr("checked");
			results_registration_form11_3.removeAttr("checked");
			results_registration_form11_1_value.val("");
			results_registration_form11_2_value.val("");
			results_registration_form11_3_value.val("");
		}
		
		pay_offs_org_type.val(orgTypeValue);
	}
	function initTreeValueExt(treeId, treeNode) {
		
		if (!(treeNode && (treeNode.level > 0 || !treeNode.isParent))) {
			scmWarn($("#" + treeId).attr("label") + messageTip.researchAreaInvalidDisciplineCode);
			if (treeNode.level == 0) {
				$("#" + treeId).val("");
				$("#" + treeId).parents("td").find(
						"[name$='" + treeId + "_code'],[id$='" + treeId + "_code']").val("");
				$("#" + treeId).parents("td").find(
						"[name$='" + treeId + "_value'],[id$='" + treeId + "_value']").val("");
				$("#" + treeId).parents("td").find(
						"[name$='" + treeId + "_name'],[id$='" + treeId + "_name']").val("");
			}
			
			return false;
		}
		
		var str = treeNode.name;
		var obj = treeNode.parentNode;
		while (obj != null) {
			obj = obj.parentNode;
		}
		
		$("#" + treeId).parents("td").find(
				"[name$='" + treeId + "_code'],[id$='" + treeId + "_code']").val(treeNode.id);
		$("#" + treeId).parents("td").find(
				"[name$='" + treeId + "_value'],[id$='" + treeId + "_value']").val(treeNode.id);
		$("#" + treeId).parents("td").find(
				"[name$='" + treeId + "_name'],[id$='" + treeId + "_name']").val(str);
		
	}
</script>